package cc.jt.sqlapt.jsr269.apt;

import cc.jt.sqlapt.jsr269.annotation.MyData;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;

import javax.lang.model.element.Element;

public class MyDataAnnotationProcessor extends AbstractProcessor {


  @Override
  public Set<String> getSupportedAnnotationTypes() {
    Set<String> supportedAnnotationTypes = new HashSet<>();
    supportedAnnotationTypes.add(MyData.class.getCanonicalName());
    return supportedAnnotationTypes;
  }

  @Override
  public SourceVersion getSupportedSourceVersion() {
    return SourceVersion.latestSupported();
  }

  @Override
  public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
  }


  @Override
  public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    //获取标注了MyData注解的元素, 这里实际上只有类元素
    Set<? extends Element> set = roundEnv.getElementsAnnotatedWith(MyData.class);
    for (Element element : set) {
    }
    return true;
  }
}
